#include "WifiConfig_hal_sys_api.h"

//extern at_cmd_config_t g_at_cmd_config;

//成功 0 失败 AT_ERR_FAILURE
__attribute__((weak)) char ak_wifi_connetct(const char *ssid, const char *pwd)
{
	/*at_cwjap_param_t cwjap_param = {0};
	memcpy(cwjap_param.pwd, pwd, 64);
	memcpy(cwjap_param.ssid, ssid, 32);
	//增加重连标志
    if (axk_hal_conn_ap_info_set(&cwjap_param) != AT_ERR_SUCCESS)
    {
        return AT_ERR_FAILURE;
    }
	memcpy(&g_at_cmd_config.wifi.sta.cwjap_param, &cwjap_param, sizeof(g_at_cmd_config.wifi.sta.cwjap_param));*/
	return 0;
}

__attribute__((weak)) void axk_at_wifi_sc_get_info_export(const char *ssid, const char *pwd)
{
    //axk_at_printf("Smart get wifi info\r\n");
    //axk_at_printf("ssid:%s\r\n", ssid);
    //axk_at_printf("password:%s\r\n", pwd);
}

__attribute__((weak)) at_wifi_state_t WifiConfigGetWifiStatus(){
	//return AT_WIFI_STATE_CONNECTED_GOT_IP;
	return AT_WIFI_STATE_NOT_STARTUP;
}

__attribute__((weak)) int axk_hal_thread_create(at_hal_threadParams_t *params){
    return 128;
}

__attribute__((weak)) void axk_at_wifi_sc_connect_ap_success_export(const char *ssid, const char *pwd)
{
    /*strcpy(g_at_cmd_config.wifi.sta.cwjap_param.ssid, ssid);
    strcpy(g_at_cmd_config.wifi.sta.cwjap_param.pwd, pwd);

    at_nv_save_cwjap();

    axk_at_printf("Smartconfig connected Wi-Fi\r\n");*/
}

__attribute__((weak)) void wifi_event_register(wifi_evt_cb cb)
{
    //wifi_event_cb = cb;
}

__attribute__((weak)) int axk_hal_thread_destroy(at_hal_threadParams_t *params)
{
	return -1;
    /*if(params->thread_id == NULL)
    {
        return -1;
    }
    vTaskDelete((TaskHandle_t)params->thread_id);
    return 0;*/
}

/*
__attribute__((weak)) void wifi_sta_connect_sc(const char *ssid, const char *pwd, int channel)
{
    struct ap_connect_adv ext_param = {0};
    char *hostname = (char *)_at_wifi_config.sta.hostname;
    uint32_t ip, netmask, gateway;

    if (strlen(ssid) <= 0)
    {
        return;
    }

    if (!wifi_sta_interface)
    {
        // wifi_mgmr_sta_autoconnect_disable();
        wifi_sta_interface = wifi_mgmr_sta_enable();
        wifi_mgmr_set_hostname(hostname);

        ext_param.psk = NULL;
        ext_param.ap_info.type = AP_INFO_TYPE_PRESIST;
        ext_param.ap_info.time_to_live = 5;
        ext_param.ap_info.bssid = NULL;
        ext_param.ap_info.band = 0;
        ext_param.ap_info.use_dhcp = 1;
        ext_param.ap_info.freq = wifi_channel_to_freq(channel);

        wifi_mgmr_sta_connect_ext(wifi_sta_interface, ssid, pwd, &ext_param);
    }
}
*/

// __attribute__((weak)) int axk_hal_wifi_mode_set(uint8_t mode, uint8_t auto_conn)
// {
	// return -1;
    /*wifi_ap_stop();
    wifi_sta_disconnect();

    if (mode == 0)
    {
        //nothing to do
    }
    else if (mode == 1)
    {
        if (auto_conn)
        {
            wifi_sta_connect();
        }
    }
    else if (mode == 2)
    {
        wifi_ap_start();
    }
    else if (mode == 3)
    {
        wifi_ap_start();
        if (auto_conn)
        {
            wifi_sta_connect();
        }
    }

    return 0;*/
// }

